<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>读取一行</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.readline" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">readline</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">readline</span> &mdash; <span class="dc-title">读取一行</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.readline-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>readline</strong></span>
    ([ <span class="methodparam"><span class="type">string</span> <code class="parameter">$prompt</code></span>
  ] ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   从用户端读取一行.你必须自己使用 <span class="function"><a href="readline_add_history.html" class="function">readline_add_history()</a></span> 将这一行添加到历史记录中
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.readline-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">prompt</code></dt>

     <dd>

      <p class="para">
       你可以指定一个字符串来作为用户的提示信息
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.readline-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   从用户端返回一个行字符串.返回的该行的行尾换行符会被删除
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.readline-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-694">
    <p><strong>Example #1 <span class="function"><strong>readline()</strong></span> Example</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//get&nbsp;3&nbsp;commands&nbsp;from&nbsp;user<br /></span><span style="color: #007700">for&nbsp;(</span><span style="color: #0000BB">$i</span><span style="color: #007700">=</span><span style="color: #0000BB">0</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i&nbsp;</span><span style="color: #007700">&lt;&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">;&nbsp;</span><span style="color: #0000BB">$i</span><span style="color: #007700">++)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$line&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">readline</span><span style="color: #007700">(</span><span style="color: #DD0000">"Command:&nbsp;"</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">readline_add_history</span><span style="color: #007700">(</span><span style="color: #0000BB">$line</span><span style="color: #007700">);<br />}<br /><br /></span><span style="color: #FF8000">//dump&nbsp;history<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">readline_list_history</span><span style="color: #007700">());<br /><br /></span><span style="color: #FF8000">//dump&nbsp;variables<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">readline_info</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


</div></div></div></body></html>